package klassen;




import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import Handling.GameAdmin;
import Handling.MetaAdmin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class makeMoveServlet
 */
@WebServlet(name = "makeMoveServlet", urlPatterns = {"/makeMoveServlet"})

public class makeMoveServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	public GameAdmin ga = new GameAdmin();

	

	
	
  
    /**
     * @see HttpServlet#HttpServlet()
     */
    public makeMoveServlet() {
        super();
        // TODO Auto-generated constructor stub

       
        
        
       
        
        
        
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String makeMove;
		try {
			makeMove = ga.makeMove(3,38,1);
			String[] splitResult = makeMove.split("/");
			String nummer = splitResult[0];
			String string = splitResult[1];
			
			
			try{
				out.println( "{" + "\"alertnr\":" + "\""+nummer+"\" , " + "\"text\":"+ "\""+string+"\"" + "}" );
		 } finally { out.close(); } 
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		// TODO Auto-generated method stub
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String makeMove = "1/Hallo";
		String[] splitResult = makeMove.split("/");
		String nummer = splitResult[0];
		String string = splitResult[1];
		try{
			out.println( "{" + "\"alertnr\":"+nummer+"," + "\"inhalt\":"+string+"" + "}" );
	 } finally {out.close();} 
		
	}

}
